<!DOCTYPE html>
<html>
  
<!-- Mirrored from www.dba.cn/book/electron/ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONBROWSERWINDOWMoKuai.html by HTTrack Website Copier/3.x [XR&CO'2014], Sun, 20 Mar 2022 10:24:09 GMT -->
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Electron BrowserWindow 模块 - Electron中文手册</title>
    <link rel="stylesheet" type="text/css" href="../../skins/cms/css/min-easyui.css">
    <link rel="stylesheet" type="text/css" href="../../skins/cms/css/book.css">
    <script type="text/javascript" src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="../../skins/cms/js/m-easyui.js"></script>
    <script type="text/javascript" src="../../skins/cms/js/prettify.js"></script>
  </head>
  <body class="easyui-layout" style="text-align:left">
    <div region="north" border="false" class="group wrap header" style="height:66px;font-size:100%">
      <div class="header">
        <div class="navigation-toggle" data-tools="navigation-toggle" data-target="#navbar-1">
          <span>Electron中文手册</span>
        </div>
        <div id="elogo" class="navbar navbar-left">
          <ul>
            <li>
              <h1><a href="../index.html">Electron中文手册</a></h1>
            </li>
          </ul>
        </div>
      <div style="clear:both"></div>
    </div>
   </div>
    <div region="west" split="true" data-options="collapsedSize:0,hideExpandTool:true" title="文档目录" style="width:20%;min-width:300px;padding:5px;display:none;">
        
      <ul class="easyui-tree"> 
        <li iconcls="icon-base"><span>Electron 教程</span><ul><li iconcls="icon-gears"><a href="../ELECTRONJiaoCheng/ELECTRONJiaoChengJianJie.html">Electron 教程简介</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONKuaiSuRuMen.html">Electron 快速入门</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONZhuoMianHuanJingJiCheng.html">Electron 桌面环境集成</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONZaiXianLiXianShiJianTanCe.html">Electron 在线/离线事件探测</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONJinCheng.html">Electron 进程</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONZhiChiDeCHROMEMingLingXingKaiGuan.html">Electron 支持的 Chrome 命令行开关</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONHuanJingBianLiang.html">Electron 环境变量</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONZhiChiDePingTai.html">Electron 支持的平台</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONYingYongBuShu.html">Electron 应用部署</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONXiangMACAPPSTOREYingYongTiJiaoXiangDao.html">Electron 向Mac App Store 应用提交向导</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONYingYongDaBao.html">Electron 应用打包</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONShiYongYuanShengMoKuai.html">Electron 使用原生模块</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONZhuJinChengDiaoShi.html">Electron 主进程调试</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONShiYongSELENIUMHeWEBDRIVER.html">Electron 使用 Selenium 和 WebDriver</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONDEVTOOLSKuoZhan.html">Electron DevTools扩展</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONShiYongPEPPERFLASHChaJian.html">Electron 使用 Pepper Flash 插件</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONShiYongWIDEVINECDMChaJian.html">Electron 使用 Widevine CDM 插件</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONShuYuBiao.html">Electron 术语表</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONLiPingRan.html">Electron 离屏渲染</a></li><li iconcls="icon-gears"><a  href="../ELECTRONJiaoCheng/ELECTRONJiaoHuShiJieShiQiREPL.html">Electron 交互式解释器 (REPL)</a></li></ul></li><li iconcls="icon-base"><span>Electron API</span><ul><li iconcls="icon-gears"><a  href="../ELECTRONAPI/ELECTRONDOMFILEDuiXiang.html">Electron DOM File对象</a></li><li iconcls="icon-gears"><a  href="../ELECTRONAPI/ELECTRONDOMWEBVIEWBiaoQian.html">Electron DOM <webview> 标签</a></li><li iconcls="icon-gears"><a  href="../ELECTRONAPI/ELECTRONWINDOWOPENHanShu.html">Electron window.open 函数</a></li></ul></li><li iconcls="icon-base"><span>在主进程内可用的模块</span><ul><li iconcls="icon-gears"><a  href="ELECTRONAPPMoKuai.html">Electron app 模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONAUTOUPDATERMoKuai.html">Electron autoUpdater 模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONBROWSERWINDOWMoKuai.html">Electron BrowserWindow 模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONCONTENTTRACINGMoKuai.html">Electron contentTracing 模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONDIALOGMoKuai.html">Electron dialog 模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONGLOBAL-SHORTCUTMoKuai.html">Electron global-shortcut 模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONIPCMAINMoKuai.html">Electron ipcMain 模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONMENUMoKuai.html">Electron menu 模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONMENUITEMMoKuai.html">Electron MenuItem 模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONPOWERMONITORMoKuai.html">Electron powerMonitor 模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONPOWERSAVEBLOCKERMoKuai.html">Electron powerSaveBlocker 模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONPROTOCOLMoKuai.html">Electron protocol 模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONSESSIONMoKuai.html">Electron session 模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONWEBCONTENTSMoKuai.html">Electron webContents 模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONTRAYMoKuai.html">Electron Tray 模块</a></li><li iconcls="icon-gears"><a  href="ELECTRONLOCALES.html">Electron Locales</a></li></ul></li><li iconcls="icon-base"><span>在渲染进程（网页）内可用的模块</span><ul><li iconcls="icon-gears"><a  href="../ZaiRanJinChengWangYeNeiKeYongDeMoKuai/ELECTRONDESKTOPCAPTURERMoKuai.html">Electron desktopCapturer 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiRanJinChengWangYeNeiKeYongDeMoKuai/ELECTRONIPCRENDERERMoKuai.html">Electron ipcRenderer 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiRanJinChengWangYeNeiKeYongDeMoKuai/ELECTRONREMOTEMoKuai.html">Electron remote 模块</a></li><li iconcls="icon-gears"><a  href="../ZaiRanJinChengWangYeNeiKeYongDeMoKuai/ELECTRONWEBFRAMEMoKuai.html">Electron webFrame 模块</a></li></ul></li><li iconcls="icon-base"><span>两种进程都可用的模块</span><ul><li iconcls="icon-gears"><a  href="../LiangZhongJinChengDuKeYongDeMoKuai/ELECTRONCLIPBOARDMoKuai.html">Electron clipboard 模块</a></li><li iconcls="icon-gears"><a  href="../LiangZhongJinChengDuKeYongDeMoKuai/ELECTRONCRASHREPORTERMoKuai.html">Electron crashReporter 模块</a></li><li iconcls="icon-gears"><a  href="../LiangZhongJinChengDuKeYongDeMoKuai/ELECTRONNATIVEIMAGEMoKuai.html">Electron nativeImage 模块</a></li><li iconcls="icon-gears"><a  href="../LiangZhongJinChengDuKeYongDeMoKuai/ELECTRONSCREENMoKuai.html">Electron screen 模块</a></li><li iconcls="icon-gears"><a  href="../LiangZhongJinChengDuKeYongDeMoKuai/ELECTRONSHELLMoKuai.html">Electron shell 模块</a></li></ul></li><li iconcls="icon-base"><span>Electron 开发</span><ul><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONBianMaGuiFan.html">Electron 编码规范</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONYuanMaMuLuJieGou.html">Electron 源码目录结构</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONHeNWJSYuanMingNODE-WEBKITZaiJiShuShangDeChaYi.html">Electron 和 NW.js (原名 node-webkit) 在技术上的差异</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONGouJianXiTongGaiLan.html">Electron 构建系统概览</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONGouJianBuZhouOSX.html">Electron 构建步骤 (OS X)</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONGouJianBuZhouWINDOWS.html">Electron 构建步骤 (Windows)</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONGouJianBuZhouLINUX.html">Electron 构建步骤 (Linux)</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONZaiDiaoShiZhongShiYongSYMBOLSERVER.html">Electron 在调试中使用 Symbol Server</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONChangJianWenTi.html">Electron 常见问题</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONBanBenGuanLi.html">Electron 版本管理</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONWINDOWTiJiaoZhiNan.html">electron window 提交指南</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ZiDongHuaChiXuJiChengXiTongCICeShi.html">自动化持续集成系统（CI）测试</a></li><li iconcls="icon-gears"><a  href="../ELECTRONKaiFa/ELECTRONWenDangFengGeZhiNan.html">Electron 文档风格指南</a></li></ul></li>
      </ul>
    
    </div>
    <div region="center">
      <div id="tt" class="easyui-tabs" fit="true" border="false" plain="true">
        <div title="Electron BrowserWindow 模块 - Electron中文手册">  
            <div class="book-content">
              
      <div style="padding:8px;"> &gt; <a href="../index.html">Electron中文手册</a> &gt; Electron BrowserWindow 模块</div>
      <div class="content"><p class="comments-section" ><span >BrowserWindow</span> 类让你有创建一个浏览器窗口的权力。例如:</p>
<pre ><span >// In the main process.<span ><span >
</span></span></span><span >const</span> BrowserWindow = <span >require</span>(<span >'electron'</span>).BrowserWindow;

<span >// Or in the renderer process.</span>
<span >const</span> BrowserWindow = <span >require</span>(<span >'electron'</span>).remote.BrowserWindow;

<span >var</span> win = <span >new</span> BrowserWindow({ width: <span >800</span>, height: <span >600</span>, show: <span >false</span> });
win.on(<span >'closed'</span>, <span >function<span >(</span></span>) {
  win = <span >null</span>;
});

win.loadURL(<span >'https://github.com'</span>);
win.show();
</pre>
<p class="comments-section" >你也可以不通过chrome创建窗口，使用<span> </span><span >Frameless Window</span><span> </span>API.</p>
<h2 id="class-browserwindow" >Class: BrowserWindow</h2>
<p class="comments-section" ><span ><span >BrowserWindow</span></span><span> </span>是一个<span> </span>EventEmitter.</p>
<p class="comments-section" >通过<span> </span><span ><span >options</span></span><span> </span>可以创建一个具有本质属性的<span> </span><span ><span >BrowserWindow</span></span><span> </span>。</p>
<h3 id="new-browserwindowoptions" ><span ><span >new BrowserWindow([options])</span></span></h3>
<ul ><li >
<span ><span >options</span></span><span> </span>Object<ul >
<li >
<span ><span >width</span></span><span> </span>Integer - 窗口宽度,单位像素. 默认是<span> </span><span ><span >800</span></span>。</li>
<li >
<span ><span >height</span></span><span> </span>Integer - 窗口高度,单位像素. 默认是<span> </span><span ><span >600</span></span>。</li>
<li >
<span ><span >x</span></span><span> </span>Integer - 窗口相对于屏幕的左偏移位置.默认居中。</li>
<li >
<span ><span >y</span></span><span> </span>Integer - 窗口相对于屏幕的顶部偏移位置.默认居中。</li>
<li >
<span ><span >useContentSize</span></span><span> </span>Boolean -<span> </span><span ><span >width</span></span><span> </span>和<span> </span><span ><span >height</span></span><span> </span>使用web网页size, 这意味着实际窗口的size应该包括窗口框架的size，稍微会大一点，默认为<span> </span><span ><span >false</span></span>。</li>
<li >
<span ><span >center</span></span><span> </span>Boolean - 窗口屏幕居中。</li>
<li >
<span ><span >minWidth</span></span><span> </span>Integer - 窗口最小宽度，默认为<span> </span><span ><span >0</span></span>。</li>
<li >
<span ><span >minHeight</span></span><span> </span>Integer - 窗口最小高度，默认为<span> </span><span ><span >0</span></span>。</li>
<li >
<span ><span >maxWidth</span></span><span> </span>Integer - 窗口最大宽度，默认无限制。</li>
<li >
<span ><span >maxHeight</span></span><span> </span>Integer - 窗口最大高度，默认无限制。</li>
<li >
<span ><span >resizable</span></span><span> </span>Boolean - 是否可以改变窗口size，默认为<span> </span><span ><span >true</span></span>。</li>
<li >
<span ><span >movable</span></span><span> </span>Boolean - 窗口是否可以拖动. 在 Linux 上无效. 默认为<span> </span><span ><span >true</span></span>。</li>
<li >
<span ><span >minimizable</span></span><span> </span>Boolean - 窗口是否可以最小化. 在 Linux 上无效. 默认为<span> </span><span ><span >true</span></span>。</li>
<li >
<span ><span >maximizable</span></span><span> </span>Boolean - 窗口是否可以最大化. 在 Linux 上无效. 默认为<span> </span><span ><span >true</span></span>。</li>
<li >
<span ><span >closable</span></span><span> </span>Boolean - 窗口是否可以关闭. 在 Linux 上无效. 默认为<span> </span><span ><span >true</span></span>。</li>
<li >
<span ><span >alwaysOnTop</span></span><span> </span>Boolean - 窗口是否总是显示在其他窗口之前. 在 Linux 上无效. 默认为<span> </span><span ><span >false</span></span>。</li>
<li >
<span ><span >fullscreen</span></span><span> </span>Boolean - 窗口是否可以全屏幕. 当明确设置值为When<span> </span><span ><span >false</span></span><span> </span>，全屏化按钮将会隐藏，在 OS X 将禁用. 默认<span> </span><span ><span >false</span></span>。</li>
<li >
<span ><span >fullscreenable</span></span><span> </span>Boolean - 在 OS X 上，全屏化按钮是否可用，默认为<span> </span><span ><span >true</span></span>。</li>
<li >
<span ><span >skipTaskbar</span></span><span> </span>Boolean - 是否在人物栏中显示窗口. 默认是<span ><span >false</span></span>。</li>
<li >
<span ><span >kiosk</span></span><span> </span>Boolean - kiosk 方式. 默认为<span> </span><span ><span >false</span></span>。</li>
<li >
<span ><span >title</span></span><span> </span>String - 窗口默认title. 默认<span> </span><span ><span >"Electron"</span></span>。</li>
<li >
<span ><span >icon</span></span><span> </span><a href="NATIVEIMAGE.html">NativeImage</a><span> </span>- 窗口图标, 如果不设置，窗口将使用可用的默认图标。</li>
<li >
<span ><span >show</span></span><span> </span>Boolean - 窗口创建的时候是否显示. 默认为<span> </span><span ><span >true</span></span>。</li>
<li >
<span ><span >frame</span></span><span> </span>Boolean - 指定<span> </span><span ><span >false</span></span><span> </span>来创建一个<span> </span><span >Frameless Window</span>. 默认为<span> </span><span ><span >true</span></span>。</li>
<li >
<span ><span >acceptFirstMouse</span></span><span> </span>Boolean - 是否允许单击web view来激活窗口。默认为<span> </span><span ><span >false</span></span>。</li>
<li >
<span ><span >disableAutoHideCursor</span></span><span> </span>Boolean - 当 typing 时是否隐藏鼠标.默认<span> </span><span ><span >false</span></span>。</li>
<li >
<span ><span >autoHideMenuBar</span></span><span> </span>Boolean - 除非点击<span> </span><span ><span >Alt</span></span>，否则隐藏菜单栏.默认为<span> </span><span ><span >false</span></span>。</li>
<li >
<span ><span >enableLargerThanScreen</span></span><span> </span>Boolean - 是否允许允许改变窗口大小大于屏幕. 默认是<span> </span><span ><span >false</span></span>。</li>
<li >
<span ><span >backgroundColor</span></span><span> </span>String -窗口的 background color 值为十六进制，如<span> </span><span ><span >#66CD00</span></span><span> </span>或<span> </span><span ><span >#FFF</span></span><span> </span>或<span> </span><span ><span >#80FFFFFF</span></span><span> </span>(支持透明度)。默认为在 Linux 和 Windows 上为<span> </span><span ><span >#000</span></span><span> </span>(黑色)，Mac上为<span> </span><span ><span >#FFF</span></span>(或透明)。</li>
<li >
<span ><span >hasShadow</span></span><span> </span>Boolean - 窗口是否有阴影。只在 OS X 上有效. 默认为<span> </span><span ><span >true</span></span>。</li>
<li >
<span ><span >darkTheme</span></span><span> </span>Boolean - 为窗口使用 dark 主题，只在一些拥有 GTK+3 桌面环境上有效. 默认为<span> </span><span ><span >false</span></span>。</li>
<li >
<span ><span >transparent</span></span><span> </span>Boolean - 窗口<span >透明</span>。默认为<span> </span><span ><span >false</span></span>。</li>
<li >
<span ><span >type</span></span><span> </span>String - 窗口type，默认普通窗口，下面查看更多。</li>
<li >
<span ><span >titleBarStyle</span></span><span> </span>String - 窗口标题栏样式，下面查看更多。</li>
<li >
<span ><span >webPreferences</span></span><span> </span>Object - 设置界面特性，下面查看更多。</li>
</ul>
</li></ul>
<p class="comments-section" ><span ><span >type</span></span><span> </span>的值和效果不同平台展示效果不同，具体:</p>
<ul >
<li >Linux，可用值为<span> </span><span ><span >desktop</span></span>，<span> </span><span ><span >dock</span></span>，<span> </span><span ><span >toolbar</span></span>，<span> </span><span ><span >splash</span></span>，<span> </span><span ><span >notification</span></span>。</li>
<li >OS X，可用值为<span> </span><span ><span >desktop</span></span>，<span> </span><span ><span >textured</span></span>。<ul >
<li >
<span ><span >textured</span></span><span> </span>type 添加金属梯度效果 (<span ><span >NSTexturedBackgroundWindowMask</span></span>)。</li>
<li >
<span ><span >desktop</span></span><span> </span>设置窗口在桌面背景窗口水平 (<span ><span >kCGDesktopWindowLevel - 1</span></span>)。注意桌面窗口不可聚焦，不可不支持键盘和鼠标事件，但是可以使用<span> </span><span ><span >globalShortcut</span></span><span> </span>来解决输入问题。</li>
</ul>
</li>
</ul>
<p class="comments-section" ><span ><span >titleBarStyle</span></span><span> </span>只在 OS X 10.10 Yosemite 或更新版本上支持，可用值：</p>
<ul >
<li >
<span ><span >default</span></span><span> </span>以及无值, 显示在 Mac 标题栏上为不透明的标准灰色。</li>
<li >
<span ><span >hidden</span></span><span> </span>隐藏标题栏，内容充满整个窗口, 然后它依然在左上角，仍然受标准窗口控制。</li>
<li >
<span ><span >hidden-inset</span></span>主体隐藏，显示小的控制按钮在窗口边缘。</li>
</ul>
<p class="comments-section" ><span ><span >webPreferences</span></span><span> </span>参数是个对象，它的属性：</p>
<ul >
<li >
<span ><span >nodeIntegration</span></span><span> </span>Boolean - 是否完整支持node。默认为<span> </span><span ><span >true</span></span>。</li>
<li >
<span ><span >preload</span></span><span> </span>String - 界面的其它脚本运行之前预先加载一个指定脚本。这个脚本将一直可以使用 node APIs 无论 node integration 是否开启。脚本路径为绝对路径。当 node integration 关闭，预加载的脚本将从全局范围重新引入node的全局引用标志。查看例子<span> </span><a href="HERE.html">here</a>。</li>
<li >
<span ><span >session</span></span><span> </span><a href="SESSION.html">Session</a><span> </span>- 设置界面session。而不是直接忽略session对象，也可用<span> </span><span ><span >partition</span></span><span> </span>来代替，它接受一个 partition 字符串。当同时使用<span> </span><span ><span >session</span></span><span> </span>和<span> </span><span ><span >partition</span></span>，<span> </span><span ><span >session</span></span><span> </span>优先级更高. 默认使用默认 session。</li>
<li >
<span ><span >partition</span></span><span> </span>String - 通过session的partition字符串来设置界面session. 如果<span> </span><span ><span >partition</span></span><span> </span>以<span> </span><span ><span >persist:</span></span>开头, 这个界面将会为所有界面使用相同的<span> </span><span ><span >partition</span></span>. 如果没有<span> </span><span ><span >persist:</span></span><span> </span>前缀, 界面使用历史session. 通过分享同一个<span> </span><span ><span >partition</span></span>，所有界面使用相同的session. 默认使用默认 session.</li>
<li >
<span ><span >zoomFactor</span></span><span> </span>Number - 界面默认缩放值，<span ><span >3.0</span></span><span> </span>表示<span> </span><span ><span >300%</span></span>. 默认<span> </span><span ><span >1.0</span></span>.</li>
<li >
<span ><span >javascript</span></span><span> </span>Boolean - 开启javascript支持. 默认为<span ><span >true</span></span>.</li>
<li >
<span ><span >webSecurity</span></span><span> </span>Boolean - 当设置为<span> </span><span ><span >false</span></span>，它将禁用相同地方的规则 (通常测试服), 并且如果有2个非用户设置的参数，就设置<span> </span><span ><span >allowDisplayingInsecureContent</span></span><span> </span>和<span> </span><span ><span >allowRunningInsecureContent</span></span><span> </span>的值为<span ><span >true</span></span>. 默认为<span> </span><span ><span >true</span></span>.</li>
<li >
<span ><span >allowDisplayingInsecureContent</span></span><span> </span>Boolean -允许一个使用 https的界面来展示由 http URLs 传过来的资源. 默认<span ><span >false</span></span>.</li>
<li >
<span ><span >allowRunningInsecureContent</span></span><span> </span>Boolean - Boolean -允许一个使用 https的界面来渲染由 http URLs 提交的html,css,javascript. 默认为<span> </span><span ><span >false</span></span>。</li>
<li >
<span ><span >images</span></span><span> </span>Boolean - 开启图片使用支持. 默认<span> </span><span ><span >true</span></span>.</li>
<li >
<span ><span >textAreasAreResizable</span></span><span> </span>Boolean - textArea 可以编辑. 默认为<span> </span><span ><span >true</span></span>.</li>
<li >
<span ><span >webgl</span></span><span> </span>Boolean - 开启 WebGL 支持. 默认为<span> </span><span ><span >true</span></span>.</li>
<li >
<span ><span >webaudio</span></span><span> </span>Boolean - 开启 WebAudio 支持. 默认为<span> </span><span ><span >true</span></span>.</li>
<li >
<span ><span >plugins</span></span><span> </span>Boolean - 是否开启插件支持. 默认为<span> </span><span ><span >false</span></span>.</li>
<li >
<span ><span >experimentalFeatures</span></span><span> </span>Boolean - 开启 Chromium 的 可测试 特性. 默认为<span> </span><span ><span >false</span></span>.</li>
<li >
<span ><span >experimentalCanvasFeatures</span></span><span> </span>Boolean - 开启 Chromium 的 canvas 可测试特性. 默认为<span> </span><span ><span >false</span></span>.</li>
<li >
<span ><span >directWrite</span></span><span> </span>Boolean - 开启窗口的 DirectWrite font 渲染系统. 默认为<span> </span><span ><span >true</span></span>.</li>
<li >
<span ><span >blinkFeatures</span></span><span> </span>String - 以<span> </span><span ><span >,</span></span><span> </span>分隔的特性列表, 如<span> </span><span ><span >CSSVariables,KeyboardEventKey</span></span>. 被支持的所有特性可在<span> </span>setFeatureEnabledFromString<span> </span>中找到.</li>
<li >
<span ><span >defaultFontFamily</span></span><span> </span>Object - 设置 font-family 默认字体.<ul >
<li >
<span ><span >standard</span></span><span> </span>String - 默认为<span> </span><span ><span >Times New Roman</span></span>.</li>
<li >
<span ><span >serif</span></span><span> </span>String - 默认为<span> </span><span ><span >Times New Roman</span></span>.</li>
<li >
<span ><span >sansSerif</span></span><span> </span>String - 默认为<span> </span><span ><span >Arial</span></span>.</li>
<li >
<span ><span >monospace</span></span><span> </span>String - 默认为<span> </span><span ><span >Courier New</span></span>.</li>
</ul>
</li>
<li >
<span ><span >defaultFontSize</span></span><span> </span>Integer - 默认为<span> </span><span ><span >16</span></span>.</li>
<li >
<span ><span >defaultMonospaceFontSize</span></span><span> </span>Integer - 默认为<span> </span><span ><span >13</span></span>.</li>
<li >
<span ><span >minimumFontSize</span></span><span> </span>Integer - 默认为<span> </span><span ><span >0</span></span>.</li>
<li >
<span ><span >defaultEncoding</span></span><span> </span>String - 默认为<span> </span><span ><span >ISO-8859-1</span></span>.</li>
</ul>
<h2 id="事件" >事件</h2>
<p class="comments-section" ><span ><span >BrowserWindow</span></span><span> </span>对象可触发下列事件:</p>
<p class="comments-section" ><span >注意:</span><span> </span>一些事件只能在特定os环境中触发，已经尽可能地标出.</p>
<h3 id="event-pagetitleupdated" >Event: 'page-title-updated'</h3>
<p >返回:</p>
<ul ><li >
<span ><span >event</span></span><span> </span>Event</li></ul>
<p class="comments-section" >当文档改变标题时触发,使用<span> </span><span ><span >event.preventDefault()</span></span><span> </span>可以阻止原窗口的标题改变.</p>
<h3 id="event-close" >Event: 'close'</h3>
<p >返回:</p>
<ul ><li >
<span ><span >event</span></span><span> </span>Event</li></ul>
<p class="comments-section" >在窗口要关闭的时候触发. 它在DOM的<span> </span><span ><span >beforeunload</span></span><span> </span>and<span> </span><span ><span >unload</span></span><span> </span>事件之前触发.使用<span> </span><span ><span >event.preventDefault()</span></span><span> </span>可以取消这个操作</p>
<p class="comments-section" >通常你想通过<span> </span><span ><span >beforeunload</span></span><span> </span>处理器来决定是否关闭窗口，但是它也会在窗口重载的时候被触发。在 Electron 中，返回一个空的字符串或<span> </span><span ><span >false</span></span><span> </span>可以取消关闭.例如:</p>
<pre ><span >window<span >.onbeforeunload = </span></span><span >function<span >(</span>e</span>) {
  <span >console</span>.log(<span >'I do not want to be closed'</span>);

  <span >// Unlike usual browsers, in which a string should be returned and the user is</span>
  <span >// prompted to confirm the page unload, Electron gives developers more options.</span>
  <span >// Returning empty string or false would prevent the unloading now.</span>
  <span >// You can also use the dialog API to let the user confirm closing the application.</span>
  e.returnValue = <span >false</span>;
};
</pre>
<h3 id="event-closed" >Event: 'closed'</h3>
<p class="comments-section" >当窗口已经关闭的时候触发.当你接收到这个事件的时候，你应当删除对已经关闭的窗口的引用对象和避免再次使用它.</p>
<h3 id="event-unresponsive" >Event: 'unresponsive'</h3>
<p class="comments-section" >在界面卡死的时候触发事件.</p>
<h3 id="event-responsive" >Event: 'responsive'</h3>
<p class="comments-section" >在界面恢复卡死的时候触发.</p>
<h3 id="event-blur" >Event: 'blur'</h3>
<p class="comments-section" >在窗口失去焦点的时候触发.</p>
<h3 id="event-focus" >Event: 'focus'</h3>
<p class="comments-section" >在窗口获得焦点的时候触发.</p>
<h3 id="event-maximize" >Event: 'maximize'</h3>
<p class="comments-section" >在窗口最大化的时候触发.</p>
<h3 id="event-unmaximize" >Event: 'unmaximize'</h3>
<p class="comments-section" >在窗口退出最大化的时候触发.</p>
<h3 id="event-minimize" >Event: 'minimize'</h3>
<p class="comments-section" >在窗口最小化的时候触发.</p>
<h3 id="event-restore" >Event: 'restore'</h3>
<p class="comments-section" >在窗口从最小化恢复的时候触发.</p>
<h3 id="event-resize" >Event: 'resize'</h3>
<p class="comments-section" >在窗口size改变的时候触发.</p>
<h3 id="event-move" >Event: 'move'</h3>
<p class="comments-section" >在窗口移动的时候触发.</p>
<p class="comments-section" >注意：在 OS X 中别名为<span> </span><span ><span >moved</span></span>.</p>
<h3 id="event-moved-os-x" >Event: 'moved'<span> </span><span >OS X</span>
</h3>
<p class="comments-section" >在窗口移动的时候触发.</p>
<h3 id="event-enterfullscreen" >Event: 'enter-full-screen'</h3>
<p class="comments-section" >在的窗口进入全屏状态时候触发.</p>
<h3 id="event-leavefullscreen" >Event: 'leave-full-screen'</h3>
<p class="comments-section" >在的窗口退出全屏状态时候触发.</p>
<h3 id="event-enterhtmlfullscreen" >Event: 'enter-html-full-screen'</h3>
<p class="comments-section" >在的窗口通过 html api 进入全屏状态时候触发.</p>
<h3 id="event-leavehtmlfullscreen" >Event: 'leave-html-full-screen'</h3>
<p class="comments-section" >在的窗口通过 html api 退出全屏状态时候触发.</p>
<h3 id="event-appcommand-windows" >Event: 'app-command'<span> </span><span >Windows</span>
</h3>
<p class="comments-section" >在请求一个<span >App Command</span>.aspx)的时候触发. 典型的是键盘媒体或浏览器命令, Windows上的 "Back" 按钮用作鼠标也会触发.</p>
<pre ><span >someWindow.on(</span><span >'app-command'</span>, <span >function<span >(</span>e, cmd</span>) {
  <span >// Navigate the window back when the user hits their mouse back button</span>
  <span >if</span> (cmd === <span >'browser-backward'</span> &amp;&amp; someWindow.webContents.canGoBack()) {
    someWindow.webContents.goBack();
  }
});
</pre>
<h3 id="event-scrolltouchbegin-os-x" >Event: 'scroll-touch-begin'<span> </span><span >OS X</span>
</h3>
<p class="comments-section" >在滚动条事件开始的时候触发.</p>
<h3 id="event-scrolltouchend-os-x" >Event: 'scroll-touch-end'<span> </span><span >OS X</span>
</h3>
<p class="comments-section" >在滚动条事件结束的时候触发.</p>
<h2 id="方法" >方法</h2>
<p class="comments-section" ><span ><span >BrowserWindow</span></span><span> </span>对象有如下方法:</p>
<h3 id="browserwindowgetallwindows" ><span ><span >BrowserWindow.getAllWindows()</span></span></h3>
<p class="comments-section" >返回一个所有已经打开了窗口的对象数组.</p>
<h3 id="browserwindowgetfocusedwindow" ><span ><span >BrowserWindow.getFocusedWindow()</span></span></h3>
<p class="comments-section" >返回应用当前获得焦点窗口,如果没有就返回<span> </span><span ><span >null</span></span>.</p>
<h3 id="browserwindowfromwebcontentswebcontents" ><span ><span >BrowserWindow.fromWebContents(webContents)</span></span></h3>
<ul ><li >
<span ><span >webContents</span></span><span> </span><a href="WEBCONTENTS.html">WebContents</a>
</li></ul>
<p class="comments-section" >根据<span> </span><span ><span >webContents</span></span><span> </span>查找窗口.</p>
<h3 id="browserwindowfromidid" ><span ><span >BrowserWindow.fromId(id)</span></span></h3>
<ul ><li >
<span ><span >id</span></span><span> </span>Integer</li></ul>
<p class="comments-section" >根据 id 查找窗口.</p>
<h3 id="browserwindowadddevtoolsextensionpath" ><span ><span >BrowserWindow.addDevToolsExtension(path)</span></span></h3>
<ul ><li >
<span ><span >path</span></span><span> </span>String</li></ul>
<p class="comments-section" >添加位于<span> </span><span ><span >path</span></span><span> </span>的开发者工具栏扩展,并且返回扩展项的名字.</p>
<p class="comments-section" >这个扩展会被添加到历史，所以只需要使用这个API一次，这个api不可用作编程使用.</p>
<h3 id="browserwindowremovedevtoolsextensionname" ><span ><span >BrowserWindow.removeDevToolsExtension(name)</span></span></h3>
<ul ><li >
<span ><span >name</span></span><span> </span>String</li></ul>
<p class="comments-section" >删除开发者工具栏名为<span> </span><span ><span >name</span></span><span> </span>的扩展.</p>
<h2 id="实例属性" >实例属性</h2>
<p class="comments-section" >使用<span> </span><span ><span >new BrowserWindow</span></span><span> </span>创建的实例对象，有如下属性:</p>
<pre ><span >// In this example `win` is our instance<span ><span >
</span></span></span><span >var</span> win = <span >new</span> BrowserWindow({ width: <span >800</span>, height: <span >600</span> });
</pre>
<h3 id="winwebcontents" ><span ><span >win.webContents</span></span></h3>
<p class="comments-section" >这个窗口的<span> </span><span ><span >WebContents</span></span><span> </span>对象，所有与界面相关的事件和方法都通过它完成的.</p>
<p class="comments-section" >查看<span> </span><a href="WEBCONTENTS.html">webContents</a><span > </span><span >documentation</span><span> </span>的方法和事件.</p>
<h3 id="winid" ><span ><span >win.id</span></span></h3>
<p class="comments-section" >窗口的唯一id.</p>
<h2 id="实例方法" >实例方法</h2>
<p class="comments-section" >使用<span> </span><span ><span >new BrowserWindow</span></span><span> </span>创建的实例对象，有如下方法:</p>
<p class="comments-section" ><span >注意:</span><span> </span>一些方法只能在特定os环境中调用，已经尽可能地标出.</p>
<h3 id="windestroy" ><span ><span >win.destroy()</span></span></h3>
<p class="comments-section" >强制关闭窗口,<span> </span><span ><span >unload</span></span><span> </span>and<span> </span><span ><span >beforeunload</span></span><span> </span>不会触发，并且<span> </span><span ><span >close</span></span><span> </span>也不会触发, 但是它保证了<span> </span><span ><span >closed</span></span><span> </span>触发.</p>
<h3 id="winclose" ><span ><span >win.close()</span></span></h3>
<p class="comments-section" >尝试关闭窗口，这与用户点击关闭按钮的效果一样. 虽然网页可能会取消关闭，查看<span> </span><span >close event</span>.</p>
<h3 id="winfocus" ><span ><span >win.focus()</span></span></h3>
<p class="comments-section" >窗口获得焦点.</p>
<h3 id="winisfocused" ><span ><span >win.isFocused()</span></span></h3>
<p class="comments-section" >返回 boolean, 窗口是否获得焦点.</p>
<h3 id="winshow" ><span ><span >win.show()</span></span></h3>
<p class="comments-section" >展示并且使窗口获得焦点.</p>
<h3 id="winshowinactive" ><span ><span >win.showInactive()</span></span></h3>
<p class="comments-section" >展示窗口但是不获得焦点.</p>
<h3 id="winhide" ><span ><span >win.hide()</span></span></h3>
<p class="comments-section" >隐藏窗口.</p>
<h3 id="winisvisible" ><span ><span >win.isVisible()</span></span></h3>
<p class="comments-section" >返回 boolean, 窗口是否可见.</p>
<h3 id="winmaximize" ><span ><span >win.maximize()</span></span></h3>
<p class="comments-section" >窗口最大化.</p>
<h3 id="winunmaximize" ><span ><span >win.unmaximize()</span></span></h3>
<p class="comments-section" >取消窗口最大化.</p>
<h3 id="winismaximized" ><span ><span >win.isMaximized()</span></span></h3>
<p class="comments-section" >返回 boolean, 窗口是否最大化.</p>
<h3 id="winminimize" ><span ><span >win.minimize()</span></span></h3>
<p class="comments-section" >窗口最小化. 在一些os中，它将在dock中显示.</p>
<h3 id="winrestore" ><span ><span >win.restore()</span></span></h3>
<p class="comments-section" >将最小化的窗口恢复为之前的状态.</p>
<h3 id="winisminimized" ><span ><span >win.isMinimized()</span></span></h3>
<p class="comments-section" >返回 boolean, 窗口是否最小化.</p>
<h3 id="winsetfullscreenflag" ><span ><span >win.setFullScreen(flag)</span></span></h3>
<ul ><li >
<span ><span >flag</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >设置是否全屏.</p>
<h3 id="winisfullscreen" ><span ><span >win.isFullScreen()</span></span></h3>
<p class="comments-section" >返回 boolean, 窗口是否全屏化.</p>
<h3 id="winsetaspectratioaspectratio-extrasize-os-x" >
<span ><span >win.setAspectRatio(aspectRatio[, extraSize])</span></span><span> </span><span >OS X</span>
</h3>
<ul >
<li >
<span ><span >aspectRatio</span></span><span> </span>维持部分视图内容窗口的高宽比值.</li>
<li >
<span ><span >extraSize</span></span><span> </span>Object (可选) - 维持高宽比值时不包含的额外size.<ul >
<li >
<span ><span >width</span></span><span> </span>Integer</li>
<li >
<span ><span >height</span></span><span> </span>Integer</li>
</ul>
</li>
</ul>
<p class="comments-section" >由一个窗口来维持高宽比值.<span> </span><span ><span >extraSize</span></span><span> </span>允许开发者使用它，它的单位为像素，不包含在<span> </span><span ><span >aspectRatio</span></span><span> </span>中.这个 API 可用来区分窗口的size和内容的size .</p>
<p class="comments-section" >想象一个普通可控的HD video 播放器窗口. 假如左边缘有15控制像素，右边缘有25控制像素，在播放器下面有50控制像素.为了在播放器内保持一个 16:9 的高宽比例，我们可以调用这个api传入参数16/9 and [ 40, 50 ].第二个参数不管网页中的额外的宽度和高度在什么位置，只要它们存在就行.只需要把网页中的所有额外的高度和宽度加起来就行.</p>
<h3 id="winsetboundsoptions-animate" ><span ><span >win.setBounds(options[, animate])</span></span></h3>
<ul >
<li >
<span ><span >options</span></span><span> </span>Object<ul >
<li >
<span ><span >x</span></span><span> </span>Integer</li>
<li >
<span ><span >y</span></span><span> </span>Integer</li>
<li >
<span ><span >width</span></span><span> </span>Integer</li>
<li >
<span ><span >height</span></span><span> </span>Integer</li>
</ul>
</li>
<li >
<span ><span >animate</span></span><span> </span>Boolean (可选)<span> </span><span >OS X</span>
</li>
</ul>
<p class="comments-section" >重新设置窗口的宽高值，并且移动到指定的<span> </span><span ><span >x</span></span>,<span> </span><span ><span >y</span></span><span> </span>位置.</p>
<h3 id="wingetbounds" ><span ><span >win.getBounds()</span></span></h3>
<p class="comments-section" >返回一个对象，它包含了窗口的宽，高，x坐标，y坐标.</p>
<h3 id="winsetsizewidth-height-animate" ><span ><span >win.setSize(width, height[, animate])</span></span></h3>
<ul >
<li >
<span ><span >width</span></span><span> </span>Integer</li>
<li >
<span ><span >height</span></span><span> </span>Integer</li>
<li >
<span ><span >animate</span></span><span> </span>Boolean (可选)<span> </span><span >OS X</span>
</li>
</ul>
<p class="comments-section" >重新设置窗口的宽高值.</p>
<h3 id="wingetsize" ><span ><span >win.getSize()</span></span></h3>
<p class="comments-section" >返回一个数组，它包含了窗口的宽，高.</p>
<h3 id="winsetcontentsizewidth-height-animate" ><span ><span >win.setContentSize(width, height[, animate])</span></span></h3>
<ul >
<li >
<span ><span >width</span></span><span> </span>Integer</li>
<li >
<span ><span >height</span></span><span> </span>Integer</li>
<li >
<span ><span >animate</span></span><span> </span>Boolean (可选)<span> </span><span >OS X</span>
</li>
</ul>
<p class="comments-section" >重新设置窗口客户端的宽高值（例如网页界面）.</p>
<h3 id="wingetcontentsize" ><span ><span >win.getContentSize()</span></span></h3>
<p class="comments-section" >返回一个数组，它包含了窗口客户端的宽，高.</p>
<h3 id="winsetminimumsizewidth-height" ><span ><span >win.setMinimumSize(width, height)</span></span></h3>
<ul >
<li >
<span ><span >width</span></span><span> </span>Integer</li>
<li >
<span ><span >height</span></span><span> </span>Integer</li>
</ul>
<p class="comments-section" >设置窗口最小化的宽高值.</p>
<h3 id="wingetminimumsize" ><span ><span >win.getMinimumSize()</span></span></h3>
<p class="comments-section" >返回一个数组，它包含了窗口最小化的宽，高.</p>
<h3 id="winsetmaximumsizewidth-height" ><span ><span >win.setMaximumSize(width, height)</span></span></h3>
<ul >
<li >
<span ><span >width</span></span><span> </span>Integer</li>
<li >
<span ><span >height</span></span><span> </span>Integer</li>
</ul>
<p class="comments-section" >设置窗口最大化的宽高值.</p>
<h3 id="wingetmaximumsize" ><span ><span >win.getMaximumSize()</span></span></h3>
<p class="comments-section" >返回一个数组，它包含了窗口最大化的宽，高.</p>
<h3 id="winsetresizableresizable" ><span ><span >win.setResizable(resizable)</span></span></h3>
<ul ><li >
<span ><span >resizable</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >设置窗口是否可以被用户改变size.</p>
<h3 id="winisresizable" ><span ><span >win.isResizable()</span></span></h3>
<p class="comments-section" >返回 boolean,窗口是否可以被用户改变size.</p>
<h3 id="winsetmovablemovable-os-x-windows" >
<span ><span >win.setMovable(movable)</span></span><span> </span><span >OS X</span> <span >Windows</span>
</h3>
<ul ><li >
<span ><span >movable</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >设置窗口是否可以被用户拖动. Linux 无效.</p>
<h3 id="winismovable-os-x-windows" >
<span ><span >win.isMovable()</span></span><span> </span><span >OS X</span><span> </span><span >Windows</span>
</h3>
<p class="comments-section" >返回 boolean,窗口是否可以被用户拖动. Linux 总是返回<span> </span><span ><span >true</span></span>.</p>
<h3 id="winsetminimizableminimizable-os-x-windows" >
<span ><span >win.setMinimizable(minimizable)</span></span><span> </span><span >OS X</span> <span >Windows</span>
</h3>
<ul ><li >
<span ><span >minimizable</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >设置窗口是否可以最小化. Linux 无效.</p>
<h3 id="winisminimizable-os-x-windows" >
<span ><span >win.isMinimizable()</span></span><span> </span><span >OS X</span> <span >Windows</span>
</h3>
<p class="comments-section" >返回 boolean,窗口是否可以最小化. Linux 总是返回<span> </span><span ><span >true</span></span>.</p>
<h3 id="winsetmaximizablemaximizable-os-x-windows" >
<span ><span >win.setMaximizable(maximizable)</span></span><span> </span><span >OS X</span><span> </span><span >Windows</span>
</h3>
<ul ><li >
<span ><span >maximizable</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >设置窗口是否可以最大化. Linux 无效.</p>
<h3 id="winismaximizable-os-x-windows" >
<span ><span >win.isMaximizable()</span></span><span> </span><span >OS X</span> <span >Windows</span>
</h3>
<p class="comments-section" >返回 boolean,窗口是否可以最大化. Linux 总是返回<span> </span><span ><span >true</span></span>.</p>
<h3 id="winsetfullscreenablefullscreenable" ><span ><span >win.setFullScreenable(fullscreenable)</span></span></h3>
<ul ><li >
<span ><span >fullscreenable</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >设置点击最大化按钮是否可以全屏或最大化窗口.</p>
<h3 id="winisfullscreenable" ><span ><span >win.isFullScreenable()</span></span></h3>
<p class="comments-section" >返回 boolean,点击最大化按钮是否可以全屏或最大化窗口.</p>
<h3 id="winsetclosableclosable-os-x-windows" >
<span ><span >win.setClosable(closable)</span></span><span> </span><span >OS X</span><span> </span><span >Windows</span>
</h3>
<ul ><li >
<span ><span >closable</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >设置窗口是否可以人为关闭. Linux 无效.</p>
<h3 id="winisclosable-os-x-windows" >
<span ><span >win.isClosable()</span></span><span> </span><span >OS X</span><span> </span><span >Windows</span>
</h3>
<p class="comments-section" >返回 boolean,窗口是否可以人为关闭. Linux 总是返回<span> </span><span ><span >true</span></span>.</p>
<h3 id="winsetalwaysontopflag" ><span ><span >win.setAlwaysOnTop(flag)</span></span></h3>
<ul ><li >
<span ><span >flag</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >是否设置这个窗口始终在其他窗口之上.设置之后，这个窗口仍然是一个普通的窗口，不是一个不可以获得焦点的工具箱窗口.</p>
<h3 id="winisalwaysontop" ><span ><span >win.isAlwaysOnTop()</span></span></h3>
<p class="comments-section" >返回 boolean,当前窗口是否始终在其它窗口之前.</p>
<h3 id="wincenter" ><span ><span >win.center()</span></span></h3>
<p class="comments-section" >窗口居中.</p>
<h3 id="winsetpositionx-y-animate" ><span ><span >win.setPosition(x, y[, animate])</span></span></h3>
<ul >
<li >
<span ><span >x</span></span><span> </span>Integer</li>
<li >
<span ><span >y</span></span><span> </span>Integer</li>
<li >
<span ><span >animate</span></span><span> </span>Boolean (可选)<span> </span><span ><em>OS X</em></span>
</li>
</ul>
<p class="comments-section" >移动窗口到对应的<span> </span><span ><span >x</span></span><span> </span>and<span> </span><span ><span >y</span></span><span> </span>坐标.</p>
<h3 id="wingetposition" ><span ><span >win.getPosition()</span></span></h3>
<p class="comments-section" >返回一个包含当前窗口位置的数组.</p>
<h3 id="winsettitletitle" ><span ><span >win.setTitle(title)</span></span></h3>
<ul ><li >
<span ><span >title</span></span><span> </span>String</li></ul>
<p class="comments-section" >改变原窗口的title.</p>
<h3 id="wingettitle" ><span ><span >win.getTitle()</span></span></h3>
<p class="comments-section" >返回原窗口的title.</p>
<p class="comments-section" ><span >注意:</span><span> </span>界面title可能和窗口title不相同.</p>
<h3 id="winflashframeflag" ><span ><span >win.flashFrame(flag)</span></span></h3>
<ul ><li >
<span ><span >flag</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >开始或停止显示窗口来获得用户的关注.</p>
<h3 id="winsetskiptaskbarskip" ><span ><span >win.setSkipTaskbar(skip)</span></span></h3>
<ul ><li >
<span ><span >skip</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >让窗口不在任务栏中显示.</p>
<h3 id="winsetkioskflag" ><span ><span >win.setKiosk(flag)</span></span></h3>
<ul ><li >
<span ><span >flag</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >进入或离开 kiosk 模式.</p>
<h3 id="winiskiosk" ><span ><span >win.isKiosk()</span></span></h3>
<p class="comments-section" >返回 boolean,是否进入或离开 kiosk 模式.</p>
<h3 id="wingetnativewindowhandle" ><span ><span >win.getNativeWindowHandle()</span></span></h3>
<p class="comments-section" >以<span> </span><span ><span >Buffer</span></span><span> </span>形式返回这个具体平台的窗口的句柄.</p>
<p class="comments-section" >windows上句柄类型为<span> </span><span ><span >HWND</span></span><span> </span>，OS X<span> </span><span ><span >NSView*</span></span><span> </span>， Linux<span> </span><span ><span >Window</span></span>.</p>
<h3 id="winhookwindowmessagemessage-callback-windows" >
<span ><span >win.hookWindowMessage(message, callback)</span></span><span> </span><span >Windows</span>
</h3>
<ul >
<li >
<span ><span >message</span></span><span> </span>Integer</li>
<li >
<span ><span >callback</span></span><span> </span>Function</li>
</ul>
<p class="comments-section" >拦截windows 消息，在 WndProc 接收到消息时触发<span> </span><span ><span >callback</span></span>函数.</p>
<h3 id="winiswindowmessagehookedmessage-windows" >
<span ><span >win.isWindowMessageHooked(message)</span></span><span> </span><span >Windows</span>
</h3>
<ul ><li >
<span ><span >message</span></span><span> </span>Integer</li></ul>
<p class="comments-section" >返回<span> </span><span ><span >true</span></span><span> </span>or<span> </span><span ><span >false</span></span><span> </span>来代表是否拦截到消息.</p>
<h3 id="winunhookwindowmessagemessage-windows" >
<span ><span >win.unhookWindowMessage(message)</span></span><span> </span><span >Windows</span>
</h3>
<ul ><li >
<span ><span >message</span></span><span> </span>Integer</li></ul>
<p class="comments-section" >不拦截窗口消息.</p>
<h3 id="winunhookallwindowmessages-windows" >
<span ><span >win.unhookAllWindowMessages()</span></span><span> </span><span >Windows</span>
</h3>
<p class="comments-section" >窗口消息全部不拦截.</p>
<h3 id="winsetrepresentedfilenamefilename-os-x" >
<span ><span >win.setRepresentedFilename(filename)</span></span><span> </span><span >OS X</span>
</h3>
<ul ><li >
<span ><span >filename</span></span><span> </span>String</li></ul>
<p class="comments-section" >设置窗口当前文件路径，并且将这个文件的图标放在窗口标题栏上.</p>
<h3 id="wingetrepresentedfilename-os-x" >
<span ><span >win.getRepresentedFilename()</span></span><span> </span><span >OS X</span>
</h3>
<p class="comments-section" >获取窗口当前文件路径.</p>
<h3 id="winsetdocumenteditededited-os-x" >
<span ><span >win.setDocumentEdited(edited)</span></span><span> </span><span >OS X</span>
</h3>
<ul ><li >
<span ><span >edited</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >明确指出窗口文档是否可以编辑，如果可以编辑则将标题栏的图标变成灰色.</p>
<h3 id="winisdocumentedited-os-x" >
<span ><span >win.isDocumentEdited()</span></span><span> </span><span >OS X</span>
</h3>
<p class="comments-section" >返回 boolean,当前窗口文档是否可编辑.</p>
<h3 id="winfocusonwebview" ><span ><span >win.focusOnWebView()</span></span></h3>
<h3 id="winblurwebview" ><span ><span >win.blurWebView()</span></span></h3>
<h3 id="wincapturepagerect-callback" ><span ><span >win.capturePage([rect, ]callback)</span></span></h3>
<ul >
<li >
<span ><span >rect</span></span><span> </span>Object (可选) - 捕获Page位置<ul >
<li >
<span ><span >x</span></span><span> </span>Integer</li>
<li >
<span ><span >y</span></span><span> </span>Integer</li>
<li >
<span ><span >width</span></span><span> </span>Integer</li>
<li >
<span ><span >height</span></span><span> </span>Integer</li>
</ul>
</li>
<li >
<span ><span >callback</span></span><span> </span>Function</li>
</ul>
<p class="comments-section" >捕获<span> </span><span ><span >rect</span></span><span> </span>中的page 的快照.完成后将调用回调函数<span> </span><span ><span >callback</span></span><span> </span>并返回<span> </span><span ><span >image</span></span><span> </span>.<span> </span><span ><span >image</span></span><span> </span>是存储了快照信息的<a href="NATIVEIMAGE.html">NativeImage</a>实例.如果不设置<span> </span><span ><span >rect</span></span><span> </span>则将捕获所有可见page.</p>
<h3 id="winprintoptions" ><span ><span >win.print([options])</span></span></h3>
<p class="comments-section" >类似<span> </span><span ><span >webContents.print([options])</span></span></p>
<h3 id="winprinttopdfoptions-callback" ><span ><span >win.printToPDF(options, callback)</span></span></h3>
<p class="comments-section" >类似<span> </span><span ><span >webContents.printToPDF(options, callback)</span></span></p>
<h3 id="winloadurlurl-options" ><span ><span >win.loadURL(url[, options])</span></span></h3>
<p class="comments-section" >类似<span> </span><span ><span >webContents.loadURL(url[, options])</span></span>.</p>
<h3 id="winreload" ><span ><span >win.reload()</span></span></h3>
<p class="comments-section" >类似<span> </span><span ><span >webContents.reload</span></span>.</p>
<h3 id="winsetmenumenu-linux-windows" >
<span ><span >win.setMenu(menu)</span></span><span> </span><span >Linux</span><span> </span><span >Windows</span>
</h3>
<ul ><li >
<span ><span >menu</span></span><span> </span>Menu</li></ul>
<p class="comments-section" >设置菜单栏的<span> </span><span ><span >menu</span></span><span> </span>，设置它为<span> </span><span ><span >null</span></span><span> </span>则表示不设置菜单栏.</p>
<h3 id="winsetprogressbarprogress" ><span ><span >win.setProgressBar(progress)</span></span></h3>
<ul ><li >
<span ><span >progress</span></span><span> </span>Double</li></ul>
<p class="comments-section" >在进度条中设置进度值，有效范围 [0, 1.0].</p>
<p class="comments-section" >当进度小于0时则不显示进度; 当进度大于0时显示结果不确定.</p>
<p class="comments-section" >在libux上，只支持Unity桌面环境，需要指明<span> </span><span ><span >*.desktop</span></span><span> </span>文件并且在<span> </span><span ><span >package.json</span></span><span> </span>中添加文件名字.默认它为<span> </span><span ><span >app.getName().desktop</span></span>.</p>
<h3 id="winsetoverlayiconoverlay-description-windows-7" >
<span ><span >win.setOverlayIcon(overlay, description)</span></span><span> </span><span >Windows 7+</span>
</h3>
<ul >
<li >
<span ><span >overlay</span></span><span> </span><a href="NATIVEIMAGE.html">NativeImage</a><span> </span>- 在底部任务栏右边显示图标.</li>
<li >
<span ><span >description</span></span><span> </span>String - 描述.</li>
</ul>
<p class="comments-section" >向当前任务栏添加一个 16 x 16 像素的图标，通常用来覆盖一些应用的状态，或者直接来提示用户.</p>
<h3 id="winsethasshadowhasshadow-os-x" >
<span ><span >win.setHasShadow(hasShadow)</span></span><span> </span><span >OS X</span>
</h3>
<ul ><li >
<span ><span >hasShadow</span></span><span> </span>(Boolean)</li></ul>
<p class="comments-section" >设置窗口是否应该有阴影.在Windows和Linux系统无效.</p>
<h3 id="winhasshadow-os-x" >
<span ><span >win.hasShadow()</span></span><span> </span><span >OS X</span>
</h3>
<p class="comments-section" >返回 boolean,设置窗口是否有阴影.在Windows和Linux系统始终返回<span> </span><span ><span >true</span></span>.</p>
<h3 id="winsetthumbarbuttonsbuttons-windows-7" >
<span ><span >win.setThumbarButtons(buttons)</span></span><span> </span><span >Windows 7+</span>
</h3>
<ul ><li >
<span ><span >buttons</span></span><span> </span>Array</li></ul>
<p class="comments-section" >在窗口的任务栏button布局出为缩略图添加一个有特殊button的缩略图工具栏. 返回一个<span> </span><span ><span >Boolean</span></span><span> </span>对象来指示是否成功添加这个缩略图工具栏.</p>
<p class="comments-section" >因为空间有限，缩略图工具栏上的 button 数量不应该超过7个.一旦设置了，由于平台限制，就不能移动它了.但是你可使用一个空数组来调用api来清除 buttons .</p>
<p class="comments-section" >所有<span> </span><span ><span >buttons</span></span><span> </span>是一个<span> </span><span ><span >Button</span></span><span> </span>对象数组:</p>
<ul ><li >
<span ><span >Button</span></span><span> </span>Object<ul >
<li >
<span ><span >icon</span></span><span> </span><a href="NATIVEIMAGE.html">NativeImage</a><span> </span>- 在工具栏上显示的图标.</li>
<li >
<span ><span >click</span></span><span> </span>Function</li>
<li >
<span ><span >tooltip</span></span><span> </span>String (可选) - tooltip 文字.</li>
<li >
<span ><span >flags</span></span><span> </span>Array (可选) - 控制button的状态和行为. 默认它是<span> </span><span ><span >['enabled']</span></span>.</li>
</ul>
</li></ul>
<p class="comments-section" ><span ><span >flags</span></span><span> </span>是一个数组，它包含下面这些<span> Strings：</span></p>
<ul >
<li >
<span ><span >enabled</span></span><span> </span>- button 为激活状态并且开放给用户.</li>
<li >
<span ><span >disabled</span></span><span> </span>-button 不可用. 目前它有一个可见的状态来表示它不会响应你的行为.</li>
<li >
<span ><span >dismissonclick</span></span><span> </span>- 点击button，这个缩略窗口直接关闭.</li>
<li >
<span ><span >nobackground</span></span><span> </span>- 不绘制边框，仅仅使用图像.</li>
<li >
<span ><span >hidden</span></span><span> </span>- button 对用户不可见.</li>
<li >
<span ><span >noninteractive</span></span><span> </span>- button 可用但是不可响应; 也不显示按下的状态. 它的值意味着这是一个在通知单使用 button 的实例.</li>
</ul>
<h3 id="winshowdefinitionforselection-os-x" >
<span ><span >win.showDefinitionForSelection()</span></span><span> </span><span >OS X</span>
</h3>
<p class="comments-section" >在界面查找选中文字时显示弹出字典.</p>
<h3 id="winsetautohidemenubarhide" ><span ><span >win.setAutoHideMenuBar(hide)</span></span></h3>
<ul ><li >
<span ><span >hide</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >设置窗口的菜单栏是否可以自动隐藏. 一旦设置了，只有当用户按下<span> </span><span ><span >Alt</span></span><span> </span>键时则显示.</p>
<p class="comments-section" >如果菜单栏已经可见，调用<span> </span><span ><span >setAutoHideMenuBar(true)</span></span><span> </span>则不会立刻隐藏.</p>
<h3 id="winismenubarautohide" ><span ><span >win.isMenuBarAutoHide()</span></span></h3>
<p class="comments-section" >返回 boolean,窗口的菜单栏是否可以自动隐藏.</p>
<h3 id="winsetmenubarvisibilityvisible" ><span ><span >win.setMenuBarVisibility(visible)</span></span></h3>
<ul ><li >
<span ><span >visible</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >设置菜单栏是否可见.如果菜单栏自动隐藏，用户仍然可以按下<span> </span><span ><span >Alt</span></span><span> </span>键来显示.</p>
<h3 id="winismenubarvisible" ><span ><span >win.isMenuBarVisible()</span></span></h3>
<p class="comments-section" >返回 boolean,菜单栏是否可见.</p>
<h3 id="winsetvisibleonallworkspacesvisible" ><span ><span >win.setVisibleOnAllWorkspaces(visible)</span></span></h3>
<ul ><li >
<span ><span >visible</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >设置窗口是否在所有地方都可见.</p>
<p class="comments-section" ><span >注意:</span><span> </span>这个api 在windows无效.</p>
<h3 id="winisvisibleonallworkspaces" ><span ><span >win.isVisibleOnAllWorkspaces()</span></span></h3>
<p class="comments-section" >返回 boolean,窗口是否在所有地方都可见.</p>
<p class="comments-section" ><span >注意:</span><span> </span>在 windows上始终返回 false.</p>
<h3 id="winsetignoremouseeventsignore-os-x" >
<span ><span >win.setIgnoreMouseEvents(ignore)</span></span><span> </span><span >OS X</span>
</h3>
<ul ><li >
<span ><span >ignore</span></span><span> </span>Boolean</li></ul>
<p class="comments-section" >忽略窗口的所有鼠标事件.</p></div>
      <div class="prev-next" style="padding:8px;">上一篇：<a class="prev" href="ELECTRONAUTOUPDATERMoKuai.html">Electron autoUpdater 模块</a><br>下一篇：<a class="prev" href="ELECTRONCONTENTTRACINGMoKuai.html">Electron contentTracing 模块</a><br></div>
    
            </div>
        </div> 
      </div>
    </div>
  </body>

<!-- Mirrored from www.dba.cn/book/electron/ZaiZhuJinChengNeiKeYongDeMoKuai/ELECTRONBROWSERWINDOWMoKuai.html by HTTrack Website Copier/3.x [XR&CO'2014], Sun, 20 Mar 2022 10:24:10 GMT -->
</html>